package com.xiaorun.portal.spider.pipeline;

import com.xiaorun.portal.dao.EnterpriseMapper;
import com.xiaorun.portal.modal.Vo.Enterprise;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

import javax.annotation.Resource;
import java.util.List;

@Component
public class EnterprisePipeline implements Pipeline {

    @Resource
    private EnterpriseMapper enterpriseMapper;

    @Override
    public void process(ResultItems resultItems, Task task) {
        List<Enterprise> enterpriseList = (List<Enterprise>)resultItems.get("enterpriseList");
        enterpriseMapper.batchSave(enterpriseList);
    }


}
